import java.util.*;
import java.io.*;

public class Practice4 {
    /*
    链接https://www.nowcoder.com/practice/a2be806a0e5747a088670f5dc62cfa1e?tpId=230&tqId=39763&ru=/exam/oj
    动态规划打家劫舍问题, 加快读模板可以到179ms
     */
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static void main(String[] args) throws IOException{
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0;i < n;i++){
            arr[i] = in.nextInt();
        }
        //前i个里面, 选与不选的最大值
        int[] f = new int[n + 1];
        int[] g = new int[n + 1];
        for(int i = 1;i <= n;i++){
            f[i] = g[i - 1] + arr[i - 1];
            g[i] = Math.max(f[i - 1],g[i - 1]);
        }
        out.println(Math.max(f[n],g[n]));
        out.flush();
    }
}
class Read{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException{
        while(!st.hasMoreTokens()){
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }
    int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
}











